
local killed = achievements.GetValue( "U Can't Touch This", "total", 0 )

local function PlayerKilledNPC( msg )
	local victim, inflictor, attacker = msg:ReadString(), msg:ReadString(), msg:ReadEntity()
	
	local ply = LocalPlayer()
	if ( ValidEntity( ply ) && ply:WaterLevel() == 3 ) then
		if ( killed != 50 && attacker == ply && victim == "npc_manhack" ) then
			killed = math.Clamp( killed + 1, 0, 50 )
			achievements.SetValue( "U Can't Touch This", "total", killed )
			achievements.Update( "U Can't Touch This", killed / 50, killed .. "/50" )
		end
	end
	
	return victim, inflictor, attacker
end
usermessage.AddHook( "PlayerKilledNPC", "Achievements.CantTouchThis", PlayerKilledNPC )

achievements.Register( "U Can't Touch This", "Kill 50 manhacks while underwater.", "achievements/canttouchthis", killed / 50, killed .. "/50" )